package com.cleaningcloud.erp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cleaningcloud.erp.domain.ErpWareReporting;
import com.cleaningcloud.erp.domain.dto.ErpWareOverflowDto;
import com.cleaningcloud.erp.domain.vo.ErpWareOverflowVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.erp.domain.ErpWareOverflow;
import com.cleaningcloud.erp.service.IErpWareOverflowService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 报溢Controller
 * 
 * @author cleaningcloud
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/ErpWareOverflow")
public class ErpWareOverflowController extends BaseController
{
    @Autowired
    private IErpWareOverflowService erpWareOverflowService;

    /**
     * 查询报溢列表
     */
    @RequiresPermissions("erp:ErpWareOverflow:list")
    @GetMapping("/list")
    public TableDataInfo list(ErpWareOverflow erpWareOverflow)
    {
        startPage();
        List<ErpWareOverflowVo> list = erpWareOverflowService.selectErpWareOverflowList(erpWareOverflow);
        return getDataTable(list);
    }

    /**
     * 导出报溢列表
     */
    @RequiresPermissions("erp:ErpWareOverflow:export")
    @Log(title = "报溢", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpWareOverflow erpWareOverflow)
    {
        List<ErpWareOverflowVo> list = erpWareOverflowService.selectErpWareOverflowList(erpWareOverflow);
        ExcelUtil<ErpWareOverflowVo> util = new ExcelUtil<ErpWareOverflowVo>(ErpWareOverflowVo.class);
        util.exportExcel(response, list, "报溢数据");
    }

    /**
     * 获取报溢详细信息
     */
    @RequiresPermissions("erp:ErpWareOverflow:query")
    @GetMapping(value = "/{wareOverflowId}")
    public AjaxResult getInfo(@PathVariable("wareOverflowId") Long wareOverflowId)
    {
        return success(erpWareOverflowService.selectErpWareOverflowByWareOverflowId(wareOverflowId));
    }

    /**
     * 新增报溢
     */
    @RequiresPermissions("erp:ErpWareOverflow:add")
    @Log(title = "报溢", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpWareOverflowDto erpWareOverflow)
    {
        return toAjax(erpWareOverflowService.insertErpWareOverflow(erpWareOverflow));
    }

    /**
     * 修改报溢
     */
    @RequiresPermissions("erp:ErpWareOverflow:edit")
    @Log(title = "报溢", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpWareOverflowDto erpWareOverflow)
    {
        return toAjax(erpWareOverflowService.updateErpWareOverflow(erpWareOverflow));
    }

    /**
     * 审核调拨
     */
    @RequiresPermissions("erp:ErpWareOverflow:audit")
    @Log(title = "审核报溢单", businessType = BusinessType.UPDATE)
    @PutMapping("/audit")
    public AjaxResult audit(@RequestBody ErpWareOverflow erpWareOverflow)
    {
        return toAjax(erpWareOverflowService.auditErpWareOverflow(erpWareOverflow));
    }

    /**
     * 删除报溢
     */
    @RequiresPermissions("erp:ErpWareOverflow:remove")
    @Log(title = "报溢", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wareOverflowIds}")
    public AjaxResult remove(@PathVariable Long[] wareOverflowIds)
    {
        return toAjax(erpWareOverflowService.deleteErpWareOverflowByWareOverflowIds(wareOverflowIds));
    }
}
